package com.twu.biblioteca;

import java.util.HashMap;

public class UserLog {

    public static final int firstUsername = 1111111;

    private HashMap<Integer, User> userMap;
    private int curUsername;

    public UserLog() {
        curUsername = firstUsername;
        userMap = new HashMap<Integer, User>();

        addUser("a", "x", "x@a.com", 123);
        addUser("b", "y", "y@a.com", 456);
        addUser("c", "z", "z@a.com", 789);
    }

    private void addUser(String password, String name, String email, int phoneNumber) {
        userMap.put(new Integer(curUsername),
                new User(curUsername, password, name, email, phoneNumber));
                curUsername++;
    }

    public User getUser(Integer username) {
        return userMap.get(username);
    }

    public boolean isValid(Integer username) {
        return userMap.keySet().contains(username);
    }
}